{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# ERCOT: Panel dataset for NeuralProphet\n",
    "\n",
    "Takes the regular ERCOT dataset and restructures it into a panel dataset with ID column to be directly used with NeuralProphet."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "df = pd.read_csv('../datasets/multivariate/load_ercot_regions.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "regions = list(df)[1:]\n",
    "regions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_global = pd.DataFrame()\n",
    "for col in regions:\n",
    "    aux = df[[\"ds\", col]].copy(deep=True)  # select column associated with region\n",
    "    aux = aux.iloc[:26301, :].copy(deep=True)  # selects data up to 26301 row (2004 to 2007 time stamps)\n",
    "    aux = aux.rename(columns={col: \"y\"})  # rename column of data to 'y' which is compatible with Neural Prophet\n",
    "    aux[\"ID\"] = col\n",
    "    df_global = pd.concat((df_global, aux))\n",
    "df_global"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_global.to_csv('../datasets/multivariate/ercot-panel.csv', index=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.10"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
